package dao.imp;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import dao.IInfoDAO;
import domain.Information;

public class InfoDAO extends HibernateDaoSupport implements IInfoDAO {

	@Override
	public void addInfo(Information information) {
		this.getHibernateTemplate().save(information);
	}

	@Override
	public void deleteInfo(Information information) {
		this.getHibernateTemplate().delete(information);
	}

	@Override
	public List<Information> getAllInfo() {
		String hql = "from Information";
		return (List<Information>)this.getHibernateTemplate().find(hql);
	}

	@Override
	public Information getInfoByID(String id) {
		return (Information) this.getHibernateTemplate().get(Information.class, id);
	}

	@Override
	public List<Information> getInfoByTitle(String title) {
		String hql = "from Information where title = '" +title+"'";
		return (List<Information>)this.getHibernateTemplate().find(hql);
	}

	@Override
	public void updateInfo(Information information) {
		this.getHibernateTemplate().update(information);
	}


}
